USE [BD_Taller]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Cliente2]') AND parent_object_id = OBJECT_ID(N'[dbo].[Orden_Trabajo]'))
ALTER TABLE [dbo].[Orden_Trabajo] DROP CONSTRAINT [FK_Cliente2]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Empleado]') AND parent_object_id = OBJECT_ID(N'[dbo].[Orden_Trabajo]'))
ALTER TABLE [dbo].[Orden_Trabajo] DROP CONSTRAINT [FK_Empleado]
GO

USE [BD_Taller]
GO

/****** Object:  Table [dbo].[Orden_Trabajo]    Script Date: 07/19/2013 12:41:10 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Orden_Trabajo]') AND type in (N'U'))
DROP TABLE [dbo].[Orden_Trabajo]
GO

USE [BD_Taller]
GO

/****** Object:  Table [dbo].[Orden_Trabajo]    Script Date: 07/19/2013 12:41:10 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Orden_Trabajo](
	[id_Orden_Trabajo] [int] IDENTITY(1,1) NOT NULL,
	[estado] [varchar](255) NULL,
	[fecha_entrada] [datetime] NULL,
	[fecha_salida] [datetime] NULL,
	[kilometraje] [bigint] NULL,
	[nro_orden] [int] NULL,
	[id_Detalle_Orden] [int] NULL,
	[id_Servicios_Orden] [int] NULL,
	[id_Vehiculo] int not null,
	[rut_cliente] [bigint] NULL,
	[rut_empleado] [bigint] NULL,
 CONSTRAINT [PK_Orden_Trabajo] PRIMARY KEY CLUSTERED 
(
	[id_Orden_Trabajo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[Orden_Trabajo]  WITH CHECK ADD  CONSTRAINT [FK_Cliente2] FOREIGN KEY([rut_cliente])
REFERENCES [dbo].[Cliente] ([rut_Cliente])
GO

ALTER TABLE [dbo].[Orden_Trabajo] CHECK CONSTRAINT [FK_Cliente2]
GO

ALTER TABLE [dbo].[Orden_Trabajo]  WITH CHECK ADD  CONSTRAINT [FK_Empleado] FOREIGN KEY([rut_empleado])
REFERENCES [dbo].[Empleado] ([rut_Empleado])
GO

ALTER TABLE [dbo].[Orden_Trabajo] CHECK CONSTRAINT [FK_Empleado]
GO

ALTER TABLE [dbo].[Orden_Trabajo]  WITH CHECK ADD  CONSTRAINT [FK_Vehiculo] FOREIGN KEY([id_Vehiculo])
REFERENCES [dbo].[Vehiculo] ([id_Vehiculo])
GO

ALTER TABLE [dbo].[Orden_Trabajo] CHECK CONSTRAINT [FK_Vehiculo]
GO